﻿using Microsoft.AspNetCore.Mvc;
using WxBean.Core.Controllers;
using WxBean.Core.IServices;
using WxBean.Core.Model;
using WxBean.Core.Model.ViewModels.Comic;

namespace WxBean.Core.Api.Controllers
{
    /// <summary>
    /// 漫画
    /// </summary>
    [Route("api/[controller]")]
    [ApiController]
    public class ComicController : BaseApiController
    {
        public IComicService _comicService;

        public ComicController(IComicService comicService)
        {
            _comicService = comicService;
        }

        /// <summary>
        /// 查询可用网站资源漫画
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        [HttpGet("search")]
        public async Task<MessageModel<IEnumerable<ComicSearch>>> GetComicAsync(string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                var result = new MessageModel<IEnumerable<ComicSearch>>();
                result.msg = "请输入漫画名称";
                result.success = false;
                return result;
            }
            var data = await _comicService.SearchAsync(name);
            return data;
        }


    }
}
